<?php
class CountryHelper extends AppHelper{
	private $countrycod = array();
	
	var $helpers = array('Html', 'Form');
	
	function __construct(){
		$this->countrycod = array(
		    "GB"=>__("United Kingdom",true),
		    "AF"=>__("Afghanistan",true),
		    "AX"=>__("Aland Islands",true),
		    "AL"=>__("Albania",true),
		    "DZ"=>__("Algeria",true),
		    "AS"=>__("American Samoa",true),
		    "AD"=>__("Andorra",true),
		    "AO"=>__("Angola",true),
		    "AI"=>__("Anguilla",true),
		    "AQ"=>__("Antarctica",true),
		    "AG"=>__("Antigua and Barbuda",true),
		    "AR"=>__("Argentina",true),
		    "AM"=>__("Armenia",true),
		    "AW"=>__("Aruba",true),
		    "AU"=>__("Australia",true),
		    "AT"=>__("Austria",true),
		    "AZ"=>__("Azerbaijan",true),
		    "BS"=>__("Bahamas",true),
		    "BH"=>__("Bahrain",true),
		    "BD"=>__("Bangladesh",true),
		    "BB"=>__("Barbados",true),
		    "BY"=>__("Belarus",true),
		    "BE"=>__("Belgium",true),
		    "BZ"=>__("Belize",true),
		    "BJ"=>__("Benin",true),
		    "BM"=>__("Bermuda",true),
		    "BT"=>__("Bhutan",true),
		    "BO"=>__("Bolivia",true),
		    "BA"=>__("Bosnia and Herzegovina",true),
		    "BW"=>__("Botswana",true),
		    "BV"=>__("Bouvet Island",true),
		    "BR"=>__("Brazil",true),
		    "IO"=>__("British Indian Ocean Territory",true),
		    "BN"=>__("Brunei Darussalam",true),
		    "BG"=>__("Bulgaria",true),
		    "BF"=>__("Burkina Faso",true),
		    "BI"=>__("Burundi",true),
		    "KH"=>__("Cambodia",true),
		    "CM"=>__("Cameroon",true),
		    "CA"=>__("Canada",true),
		    "CV"=>__("Cape Verde",true),
		    "KY"=>__("Cayman Islands",true),
		    "CF"=>__("Central African Republic",true),
		    "TD"=>__("Chad",true),
		    "CL"=>__("Chile",true),
		    "CN"=>__("China",true),
		    "CX"=>__("Christmas Island",true),
		    "CC"=>__("Cocos (Keeling) Islands",true),
		    "CO"=>__("Colombia",true),
		    "KM"=>__("Comoros",true),
		    "CG"=>__("Congo",true),
		    "CD"=>__("Congo, The Democratic Republic of the",true),
		    "CK"=>__("Cook Islands",true),
		    "CR"=>__("Costa Rica",true),
		    "CI"=>__("Côte d'Ivoire",true),
		    "HR"=>__("Croatia",true),
		    "CU"=>__("Cuba",true),
		    "CY"=>__("Cyprus",true),
		    "CZ"=>__("Czech Republic",true),
		    "DK"=>__("Denmark",true),
		    "DJ"=>__("Djibouti",true),
		    "DM"=>__("Dominica",true),
		    "DO"=>__("Dominican Republic",true),
		    "EC"=>__("Ecuador",true),
		    "EG"=>__("Egypt",true),
		    "SV"=>__("El Salvador",true),
		    "GQ"=>__("Equatorial Guinea",true),
		    "ER"=>__("Eritrea",true),
		    "EE"=>__("Estonia",true),
		    "ET"=>__("Ethiopia",true),
		    "FK"=>__("Falkland Islands (Malvinas)",true),
		    "FO"=>__("Faroe Islands",true),
		    "FJ"=>__("Fiji",true),
		    "FI"=>__("Finland",true),
		    "FR"=>__("France",true),
		    "GF"=>__("French Guiana",true),
		    "PF"=>__("French Polynesia",true),
		    "TF"=>__("French Southern Territories",true),
		    "GA"=>__("Gabon",true),
		    "GM"=>__("Gambia",true),
		    "GE"=>__("Georgia",true),
		    "DE"=>__("Germany",true),
		    "GH"=>__("Ghana",true),
		    "GI"=>__("Gibraltar",true),
		    "GR"=>__("Greece",true),
		    "GL"=>__("Greenland",true),
		    "GD"=>__("Grenada",true),
		    "GP"=>__("Guadeloupe",true),
		    "GU"=>__("Guam",true),
		    "GT"=>__("Guatemala",true),
		    "GG"=>__("Guernsey",true),
		    "GN"=>__("Guinea",true),
		    "GW"=>__("Guinea-Bissau",true),
		    "GY"=>__("Guyana",true),
		    "HT"=>__("Haiti",true),
		    "HM"=>__("Heard Island and McDonald Islands",true),
		    "VA"=>__("Holy See (Vatican City State)",true),
		    "HN"=>__("Honduras",true),
		    "HK"=>__("Hong Kong",true),
		    "HU"=>__("Hungary",true),
		    "IS"=>__("Iceland",true),
		    "IN"=>__("India",true),
		    "ID"=>__("Indonesia",true),
		    "IR"=>__("Iran, Islamic Republic of",true),
		    "IQ"=>__("Iraq",true),
		    "IE"=>__("Ireland",true),
		    "IM"=>__("Isle of Man",true),
		    "IL"=>__("Israel",true),
		    "IT"=>__("Italy",true),
		    "JM"=>__("Jamaica",true),
		    "JP"=>__("Japan",true),
		    "JE"=>__("Jersey",true),
		    "JO"=>__("Jordan",true),
		    "KZ"=>__("Kazakhstan",true),
		    "KE"=>__("Kenya",true),
		    "KI"=>__("Kiribati",true),
		    "KP"=>__("Korea, Democratic People's Republic of",true),
		    "KR"=>__("Korea, Republic of",true),
		    "KW"=>__("Kuwait",true),
		    "KG"=>__("Kyrgyzstan",true),
		    "LA"=>__("Lao People's Democratic Republic",true),
		    "LV"=>__("Latvia",true),
		    "LB"=>__("Lebanon",true),
		    "LS"=>__("Lesotho",true),
		    "LR"=>__("Liberia",true),
		    "LY"=>__("Libyan Arab Jamahiriya",true),
		    "LI"=>__("Liechtenstein",true),
		    "LT"=>__("Lithuania",true),
		    "LU"=>__("Luxembourg",true),
		    "MO"=>__("Macao",true),
		    "MK"=>__("Macedonia, The Former Yugoslav Republic of",true),
		    "MG"=>__("Madagascar",true),
		    "MW"=>__("Malawi",true),
		    "MY"=>__("Malaysia",true),
		    "MV"=>__("Maldives",true),
		    "ML"=>__("Mali",true),
		    "MT"=>__("Malta",true),
		    "MH"=>__("Marshall Islands",true),
		    "MQ"=>__("Martinique",true),
		    "MR"=>__("Mauritania",true),
		    "MU"=>__("Mauritius",true),
		    "YT"=>__("Mayotte",true),
		    "MX"=>__("Mexico",true),
		    "FM"=>__("Micronesia, Federated States of",true),
		    "MD"=>__("Moldova",true),
		    "MC"=>__("Monaco",true),
		    "MN"=>__("Mongolia",true),
		    "ME"=>__("Montenegro",true),
		    "MS"=>__("Montserrat",true),
		    "MA"=>__("Morocco",true),
		    "MZ"=>__("Mozambique",true),
		    "MM"=>__("Myanmar",true),
		    "NA"=>__("Namibia",true),
		    "NR"=>__("Nauru",true),
		    "NP"=>__("Nepal",true),
		    "NL"=>__("Netherlands",true),
		    "AN"=>__("Netherlands Antilles",true),
		    "NC"=>__("New Caledonia",true),
		    "NZ"=>__("New Zealand",true),
		    "NI"=>__("Nicaragua",true),
		    "NE"=>__("Niger",true),
		    "NG"=>__("Nigeria",true),
		    "NU"=>__("Niue",true),
		    "NF"=>__("Norfolk Island",true),
		    "MP"=>__("Northern Mariana Islands",true),
		    "NO"=>__("Norway",true),
		    "OM"=>__("Oman",true),
		    "PK"=>__("Pakistan",true),
		    "PW"=>__("Palau",true),
		    "PS"=>__("Palestinian Territory, Occupied",true),
		    "PA"=>__("Panama",true),
		    "PG"=>__("Papua New Guinea",true),
		    "PY"=>__("Paraguay",true),
		    "PE"=>__("Peru",true),
		    "PH"=>__("Philippines",true),
		    "PN"=>__("Pitcairn",true),
		    "PL"=>__("Poland",true),
		    "PT"=>__("Portugal",true),
		    "PR"=>__("Puerto Rico",true),
		    "QA"=>__("Qatar",true),
		    "RE"=>__("Réunion",true),
		    "RO"=>__("Romania",true),
		    "RU"=>__("Russian Federation",true),
		    "RW"=>__("Rwanda",true),
		    "BL"=>__("Saint Barthélemy",true),
		    "SH"=>__("Saint Helena",true),
		    "KN"=>__("Saint Kitts and Nevis",true),
		    "LC"=>__("Saint Lucia",true),
		    "MF"=>__("Saint Martin",true),
		    "PM"=>__("Saint Pierre and Miquelon",true),
		    "VC"=>__("Saint Vincent and the Grenadines",true),
		    "WS"=>__("Samoa",true),
		    "SM"=>__("San Marino",true),
		    "ST"=>__("Sao Tome and Principe",true),
		    "SA"=>__("Saudi Arabia",true),
		    "SN"=>__("Senegal",true),
		    "RS"=>__("Serbia",true),
		    "SC"=>__("Seychelles",true),
		    "SL"=>__("Sierra Leone",true),
		    "SG"=>__("Singapore",true),
		    "SK"=>__("Slovakia",true),
		    "SI"=>__("Slovenia",true),
		    "SB"=>__("Solomon Islands",true),
		    "SO"=>__("Somalia",true),
		    "ZA"=>__("South Africa",true),
		    "GS"=>__("South Georgia and the South Sandwich Islands",true),
		    "ES"=>__("Spain",true),
		    "LK"=>__("Sri Lanka",true),
		    "SD"=>__("Sudan",true),
		    "SR"=>__("Suriname",true),
		    "SJ"=>__("Svalbard and Jan Mayen",true),
		    "SZ"=>__("Swaziland",true),
		    "SE"=>__("Sweden",true),
		    "CH"=>__("Switzerland",true),
		    "SY"=>__("Syrian Arab Republic",true),
		    "TW"=>__("Taiwan, Province of China",true),
		    "TJ"=>__("Tajikistan",true),
		    "TZ"=>__("Tanzania, United Republic of",true),
		    "TH"=>__("Thailand",true),
		    "TL"=>__("Timor-Leste",true),
		    "TG"=>__("Togo",true),
		    "TK"=>__("Tokelau",true),
		    "TO"=>__("Tonga",true),
		    "TT"=>__("Trinidad and Tobago",true),
		    "TN"=>__("Tunisia",true),
		    "TR"=>__("Turkey",true),
		    "TM"=>__("Turkmenistan",true),
		    "TC"=>__("Turks and Caicos Islands",true),
		    "TV"=>__("Tuvalu",true),
		    "UG"=>__("Uganda",true),
		    "UA"=>__("Ukraine",true),
		    "AE"=>__("United Arab Emirates",true),
		    "GB"=>__("United Kingdom",true),
		    "US"=>__("United States",true),
		    "UM"=>__("United States Minor Outlying Islands",true),
		    "UY"=>__("Uruguay",true),
		    "UZ"=>__("Uzbekistan",true),
		    "VU"=>__("Vanuatu",true),
		    "VE"=>__("Venezuela",true),
		    "VN"=>__("Viet Nam",true),
		    "VG"=>__("Virgin Islands, British",true),
		    "VI"=>__("Virgin Islands, U.S.",true),
		    "WF"=>__("Wallis and Futuna",true),
		    "EH"=>__("Western Sahara",true),
		    "YE"=>__("Yemen",true),
		    "ZM"=>__("Zambia",true),
		    "ZW"=>__("Zimbabwe",true)
	);
	}
	
	function beforeRender(){
		parent::beforeRender();
		$this->View =& ClassRegistry::getObject('view');
	}
	
	public function selectbox($field=null,$params_=array()){
		
		$params = array_merge(array('label'=>__('Country',true),'options'=>$this->countrycod),$params_);
		
		return $this->Form->input($field,$params);
	}
	
	public function name($id=null){	
		return (isset($this->countrycod[$id])) ? $this->countrycod[$id] : null;
	}
}